package com.lzw.breezeNovel.webApp.mapper.video;

import com.lzw.breezeNovel.model.entity.pojo.video.CommentLike;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.mapper.video
 * @date 2025/3/24
 * @description 评论区点赞
 */
@Mapper
@SuppressWarnings("all")
public interface CommentLikeMapper {

    /**
     * 插入评论点赞
     * @param commentLike
     */
    @Insert("insert into comment_like (comment_id,user_id,type,like_time) values (#{commentId},#{userId},#{type},#{likeTime})")
    void insert(CommentLike commentLike);

    /**
     * 删除评论点赞
     * @param commentId
     * @param userId
     * @param type
     */
    @Delete("delete from comment_like where comment_id = #{commentId} and user_id = #{userId} and type = #{type}")
    void deleteByCommentIdAndUserIdAndType(Long commentId, Long userId, Integer type);

    /**
     * 根据评论id和用户id和类型查询评论点赞
     * @param commentId
     * @param userId
     * @param type
     * @return
     */
    @Select("select  exists(select 1 from comment_like where comment_id = #{commentId} and user_id = #{userId} and type = #{type})")
    Integer selectByCommentIdAndUserIdAndType(Long commentId, Long userId, Integer type);
}
